<?php
require_once 'Controller_base.php';
use controllers\Controller_base;

class Welcome extends Controller_base {
  /**
   * Index Page for this controller.
   * Maps to the following URL
   * http://example.com/index.php/welcome
   * - or -
   * http://example.com/index.php/welcome/index
   * - or -
   * Since this controller is set as the default controller in
   * config/routes.php, it's displayed at http://example.com/
   * So any other public methods not prefixed with an underscore will
   * map to /index.php/welcome/<method_name>
   * 
   * @see http://codeigniter.com/user_guide/general/urls.html
   */
  public function index() {
    $this->load->view ( 'welcome_message' );
  }
  public function test() {
    $this->load->library ( 'doctrine' );
    $group = new Entity\UserGroup ();
    $group->setName ( 'Users' );
    
    $user = new Entity\User ();
    $user->setUsername ( 'wildlyinaccurate' );
    $user->setPassword ( 'Passw0rd' );
    $user->setEmail ( 'wildlyinaccurate@gmail.com' );
    $user->setGroup ( $group );
    
    // When you have set up your database, you can persist these entities:
    $em = $this->doctrine->em;
    $em->persist ( $group );
    $em->persist ( $user );
    $em->flush ();
    
    $this->load->view ( 'welcome_message', array (
        'user' => $user,
        'group' => $group 
    ) );
  }
  public function list_user() {
    $this->load->library ( 'doctrine' );
    $em = $this->doctrine->em;
    $data = $em->getRepository('Entity\UserGroup')
                 ->findAll();
    var_dump ( $data );
    die ();
    // $this->load->view ( 'list_user', array (
    // 'list_user' => $data
    // ) );
  }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */